package com.bwie.controller;

import com.bwie.pojo.TbCust;
import com.bwie.pojo.TbCustRecord;
import com.bwie.pojo.TbUser;
import com.bwie.service.TbUserService;
import com.bwie.utils.Result;
import com.bwie.vo.LoginInfoVo;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.PpVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author : Yoo19
 * @description :
 * @createDate : 2025/6/17 9:24 24
 */
@RestController
@RequestMapping("/user/index")
public class IndexController {
    @Autowired
    TbUserService tbUserService;


    /**
     * 发送手机验证码登陆
     * @param mobile
     * @return
     */
    @ApiOperation("发送验证码")
    @PostMapping("/sendCode/{mobile}")
    public Result sendCode(@PathVariable("mobile")String mobile){
        return tbUserService.sendCode(mobile);
    }

    /**
     * 登陆
     * @param loginInfoVo
     * @return
     */
    @ApiOperation("登陆")
    @PostMapping("/login")
    public Result login(@RequestBody @Validated LoginInfoVo loginInfoVo){
        return tbUserService.login(loginInfoVo);
    }

    /**
     * 获取客户列表+模糊查询精确查询
     * @param pageInfoVo
     * @return
     */
    @ApiOperation("获取客户列表")
    @PostMapping("/getCustList")
    public Result getCustList(@RequestBody PageInfoVo pageInfoVo){
        return tbUserService.getCustList(pageInfoVo);
    }

    /**
     * 根据类型获取字典ID
     * @param typeId
     * @return
     */
    @ApiOperation("根据type获取字典数据")
    @PostMapping("/getDictList/{typeId}")
    public Result getDictList(@PathVariable("typeId")Integer typeId){
        return tbUserService.getDictList(typeId);
    }

    /**
     * 添加客户
     * @param tbCust
     * @return
     */
    @ApiOperation("添加客户")
    @PostMapping("/addCust")
    public Result addCust(@RequestBody @Validated TbCust tbCust){
        return tbUserService.addCust(tbCust);
    }

    /**
     * 根据客户id查看详情
     * @param custId
     * @return
     */
    @ApiOperation("根据客户id查看详情")
    @PostMapping("/getCustDetail/{custId}")
    public Result getCustDetail(@PathVariable("custId")Integer custId){
        return tbUserService.getCustDetail(custId);
    }

    /**
     * 根据客户id获取联系人列表
     * @param ppVo
     * @param custId
     * @return
     */
    @ApiOperation("根据客户id获取联系人列表")
    @PostMapping("/getPeopleList/{custId}")
    public Result getPeopleList(@RequestBody PpVo ppVo,@PathVariable("custId")Integer custId){
        return tbUserService.getPeopleList(ppVo,custId);
    }
 /**
     * 根据客户id获取跟进记录列表
     * @param ppVo
     * @param custId
     * @return
     */
    @ApiOperation("根据客户id获取跟进记录列表")
    @PostMapping("/getRecord/{custId}")
    public Result getRecord(@PathVariable("custId")Integer custId){
        return tbUserService.getRecord(custId);
    }

    /**
     * 添加联系人
     * @param tbUser
     * @return
     */
    @ApiOperation("添加联系人")
    @PostMapping("/addUser")
    public Result addUser(@RequestBody TbUser tbUser){
        return tbUserService.addUser(tbUser);
    }

    @ApiOperation("获取所有角色")
    @PostMapping("/getUserRole")
    public Result getUserRole(){
        return tbUserService.getUserRole();
    }

    @ApiOperation("添加跟进")
    @PostMapping("/addRecord")
    public Result addRecord(@RequestBody TbCustRecord tbCustRecord){
        return tbUserService.addRecord(tbCustRecord);
    }

    /**
     * 新的方法添加到新的分支中
     */

    public String newFeature(){
        return "新的分支";
    }


}
